<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Completion tokens and handlers</title>
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Asio">
<link rel="up" href="../asynchronous_operations.html" title="Requirements on asynchronous operations">
<link rel="prev" href="general_asynchronous_operation_concepts.html" title="General asynchronous operation concepts">
<link rel="next" href="automatic_deduction_of_initiating_function_return_type.html" title="Automatic deduction of initiating function return type">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../../asio.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="general_asynchronous_operation_concepts.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../asynchronous_operations.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="automatic_deduction_of_initiating_function_return_type.html"><img src="../../../next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="asio.reference.asynchronous_operations.completion_token"></a><a class="link" href="completion_token.html" title="Completion tokens and handlers">Completion
        tokens and handlers</a>
</h4></div></div></div>
<p>
          Initiating functions:
        </p>
<p>
          &#8212; are function templates with template parameter <code class="computeroutput">CompletionToken</code>;
        </p>
<p>
          &#8212; accept, as the final parameter, a <span class="emphasis"><em>completion token</em></span>
          object <code class="computeroutput">token</code> of type <code class="computeroutput">CompletionToken</code>;
        </p>
<p>
          &#8212; specify a <span class="emphasis"><em>completion signature</em></span>, which is a call signature
          (C++Std [func.def]) <code class="computeroutput">Signature</code> that determines the arguments
          to the completion handler.
        </p>
<p>
          An initiating function determines the type <code class="computeroutput">CompletionHandler</code>
          of its completion handler function object by performing <code class="computeroutput">typename
          async_result&lt;decay_t&lt;CompletionToken&gt;, Signature&gt;::completion_handler_type</code>.
          The completion handler object <code class="computeroutput">completion_handler</code> is initialized
          with <code class="computeroutput">forward&lt;CompletionToken&gt;(token)</code>. [<span class="emphasis"><em>Note:</em></span>
          No other requirements are placed on the type <code class="computeroutput">CompletionToken</code>.
          &#8212;<span class="emphasis"><em>end note</em></span>]
        </p>
<p>
          The type <code class="computeroutput">CompletionHandler</code> must satisfy the requirements of
          <code class="computeroutput">Destructible</code> (C++Std [destructible]) and <code class="computeroutput">MoveConstructible</code>
          (C++Std [moveconstructible]), and be callable with the specified call signature.
        </p>
<p>
          In this library, all initiating functions specify a <span class="emphasis"><em>Completion
          signature</em></span> element that defines the call signature <code class="computeroutput">Signature</code>.
          The <span class="emphasis"><em>Completion signature</em></span> elements in this Technical
          Specification have named parameters, and the results of an asynchronous
          operation are specified in terms of these names.
        </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2018 Christopher M. Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="general_asynchronous_operation_concepts.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../asynchronous_operations.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="automatic_deduction_of_initiating_function_return_type.html"><img src="../../../next.png" alt="Next"></a>
</div>
</body>
</html>
